#! /bin/sh

cd "$(dirname "$0")"

#wxWidgets: OSX Lion, Mountain Lion, Mavericks

#adapter les variables WXVERSION, WXVER et WXPATH

#version de wxWidgets:
WXVERSION=3.1.2
#WXVER=2.9 si WXVERSION=2.9.5, WXVER=3.0 si WXVERSION=3.0.x
WXVER=3.1

#chemin de la distribution wxWidgets
WXPATH=$HOME/Documents/wxWidgets/wxWidgets-$WXVERSION

DEFINES="-D__WXOSX_COCOA__ -D_FILE_OFFSET_BITS=64 -DWX_PRECOMP -DWXUSINGDLL"
INCLUDES=" -stdlib=libc++ -I$WXPATH -I$WXPATH/lib/wx/include/osx_cocoa-unicode-static-$WXVER -I$WXPATH/include"

g++ -mmacosx-version-min=10.7 -c -Wall -Wundef -Wunused-parameter -Wno-ctor-dtor-privacy -Woverloaded-virtual -Wno-deprecated-declarations -O2 -fno-strict-aliasing -fno-common -fvisibility=hidden -fvisibility-inlines-hidden $DEFINES $INCLUDES ../../sources/wx/*.cpp ../../sources/All/*.cpp


FRAMEWORKS="-framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL"
LIBS="-lwx_osx_cocoau_stc-$WXVER -lwx_osx_cocoau_core-$WXVER -lwx_baseu-$WXVER -lwxscintilla-$WXVER -framework WebKit -lwxregexu-$WXVER -lwxpng-$WXVER -framework IOKit -framework AudioToolbox -lz -lpthread -liconv"

g++ -mmacosx-version-min=10.9 -o WinCaml *.o $FRAMEWORKS -L$WXPATH/lib $LIBS


rm *.o
mv WinCaml WinCaml7/WinCaml.app/Contents/MacOS
test -d WinCaml7/ocaml || mkdir WinCaml7/ocaml
cp -Rf ../../caml/ocaml/mac WinCaml7/ocaml
cp -Rf ../../caml/doc WinCaml7
cp -Rf ../../caml/caml-light  WinCaml7
rm -f WinCaml7/caml-light/bin/camltoplevel*
rm -f WinCaml7/bin/lintoplevel*
chmod +x WinCaml7/caml-light/bin/mactoplevel*
cp -Rf ../../caml/exemples WinCaml7

